<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: Player</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.level</a> ]
    </div>

    <h1>Coverage Summary for Class: Player (nl.tudelft.jpacman.level)</h1>

    <table class="coverageStats">
        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Class, %
            </th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">Player</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 1)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 8)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 20)
  </span>
            </td>
        </tr>

    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.level;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import java.util.Map;
        <i>4</i>&nbsp;
        <i>5</i>&nbsp;import nl.tudelft.jpacman.board.Direction;
        <i>6</i>&nbsp;import nl.tudelft.jpacman.board.Unit;
        <i>7</i>&nbsp;import nl.tudelft.jpacman.sprite.AnimatedSprite;
        <i>8</i>&nbsp;import nl.tudelft.jpacman.sprite.Sprite;
        <i>9</i>&nbsp;
        <i>10</i>&nbsp;/**
        <i>11</i>&nbsp; * A player operated unit in our game.
        <i>12</i>&nbsp; *
        <i>13</i>&nbsp; * @author Jeroen Roosen
        <i>14</i>&nbsp; */
        <i>15</i>&nbsp;public class Player extends Unit {
        <i>16</i>&nbsp;
        <i>17</i>&nbsp; /**
        <i>18</i>&nbsp; * The amount of points accumulated by this player.
        <i>19</i>&nbsp; */
        <i>20</i>&nbsp; private int score;
        <i>21</i>&nbsp;
        <i>22</i>&nbsp; /**
        <i>23</i>&nbsp; * The animations for every direction.
        <i>24</i>&nbsp; */
        <i>25</i>&nbsp; private final Map&lt;Direction, Sprite&gt; sprites;
        <i>26</i>&nbsp;
        <i>27</i>&nbsp; /**
        <i>28</i>&nbsp; * The animation that is to be played when Pac-Man dies.
        <i>29</i>&nbsp; */
        <i>30</i>&nbsp; private final AnimatedSprite deathSprite;
        <i>31</i>&nbsp;
        <i>32</i>&nbsp; /**
        <i>33</i>&nbsp; * &lt;code&gt;true&lt;/code&gt; iff this player is alive.
        <i>34</i>&nbsp; */
        <i>35</i>&nbsp; private boolean alive;
        <i>36</i>&nbsp;
        <i>37</i>&nbsp; /**
        <i>38</i>&nbsp; * {@link Unit} iff this player died by collision, &lt;code&gt;null&lt;/code&gt; otherwise.
        <i>39</i>&nbsp; */
        <i>40</i>&nbsp; private Unit killer;
        <i>41</i>&nbsp;
        <i>42</i>&nbsp; /**
        <i>43</i>&nbsp; * Creates a new player with a score of 0 points.
        <i>44</i>&nbsp; *
        <i>45</i>&nbsp; * @param spriteMap
        <i>46</i>&nbsp; * A map containing a sprite for this player for every direction.
        <i>47</i>&nbsp; * @param deathAnimation
        <i>48</i>&nbsp; * The sprite to be shown when this player dies.
        <i>49</i>&nbsp; */
        <b class="nc"><i>50</i>&nbsp; protected Player(Map&lt;Direction, Sprite&gt; spriteMap, AnimatedSprite
            deathAnimation) {</b>
        <b class="nc"><i>51</i>&nbsp; this.score = 0;</b>
        <b class="nc"><i>52</i>&nbsp; this.alive = true;</b>
        <b class="nc"><i>53</i>&nbsp; this.sprites = spriteMap;</b>
        <b class="nc"><i>54</i>&nbsp; this.deathSprite = deathAnimation;</b>
        <b class="nc"><i>55</i>&nbsp; deathSprite.setAnimating(false);</b>
        <i>56</i>&nbsp; }
        <i>57</i>&nbsp;
        <i>58</i>&nbsp; /**
        <i>59</i>&nbsp; * Returns whether this player is alive or not.
        <i>60</i>&nbsp; *
        <i>61</i>&nbsp; * @return &lt;code&gt;true&lt;/code&gt; iff the player is alive.
        <i>62</i>&nbsp; */
        <i>63</i>&nbsp; public boolean isAlive() {
        <b class="nc"><i>64</i>&nbsp; return alive;</b>
        <i>65</i>&nbsp; }
        <i>66</i>&nbsp;
        <i>67</i>&nbsp; /**
        <i>68</i>&nbsp; * Sets whether this player is alive or not.
        <i>69</i>&nbsp; *
        <i>70</i>&nbsp; * If the player comes back alive, the {@link killer} will be reset.
        <i>71</i>&nbsp; *
        <i>72</i>&nbsp; * @param isAlive
        <i>73</i>&nbsp; * &lt;code&gt;true&lt;/code&gt; iff this player is alive.
        <i>74</i>&nbsp; */
        <i>75</i>&nbsp; public void setAlive(boolean isAlive) {
        <b class="nc"><i>76</i>&nbsp; if (isAlive) {</b>
        <b class="nc"><i>77</i>&nbsp; deathSprite.setAnimating(false);</b>
        <b class="nc"><i>78</i>&nbsp; this.killer = null;</b>
        <i>79</i>&nbsp; }
        <b class="nc"><i>80</i>&nbsp; if (!isAlive) {</b>
        <b class="nc"><i>81</i>&nbsp; deathSprite.restart();</b>
        <i>82</i>&nbsp; }
        <b class="nc"><i>83</i>&nbsp; this.alive = isAlive;</b>
        <i>84</i>&nbsp; }
        <i>85</i>&nbsp;
        <i>86</i>&nbsp; /**
        <i>87</i>&nbsp; * Returns the unit that caused the death of Pac-Man.
        <i>88</i>&nbsp; *
        <i>89</i>&nbsp; * @return &lt;code&gt;Unit&lt;/code&gt; iff the player died by collision, otherwise &lt;code&gt;null&lt;/code&gt;.
        <i>90</i>&nbsp; */
        <i>91</i>&nbsp; public Unit getKiller() {
        <b class="nc"><i>92</i>&nbsp; return killer;</b>
        <i>93</i>&nbsp; }
        <i>94</i>&nbsp;
        <i>95</i>&nbsp; /**
        <i>96</i>&nbsp; * Sets the cause of death.
        <i>97</i>&nbsp; *
        <i>98</i>&nbsp; * @param killer is set if collision with ghost happens.
        <i>99</i>&nbsp; */
        <i>100</i>&nbsp; public void setKiller(Unit killer) {
        <b class="nc"><i>101</i>&nbsp; this.killer = killer;</b>
        <i>102</i>&nbsp; }
        <i>103</i>&nbsp;
        <i>104</i>&nbsp; /**
        <i>105</i>&nbsp; * Returns the amount of points accumulated by this player.
        <i>106</i>&nbsp; *
        <i>107</i>&nbsp; * @return The amount of points accumulated by this player.
        <i>108</i>&nbsp; */
        <i>109</i>&nbsp; public int getScore() {
        <b class="nc"><i>110</i>&nbsp; return score;</b>
        <i>111</i>&nbsp; }
        <i>112</i>&nbsp;
        <i>113</i>&nbsp; @Override
        <i>114</i>&nbsp; public Sprite getSprite() {
        <b class="nc"><i>115</i>&nbsp; if (isAlive()) {</b>
        <b class="nc"><i>116</i>&nbsp; return sprites.get(getDirection());</b>
        <i>117</i>&nbsp; }
        <b class="nc"><i>118</i>&nbsp; return deathSprite;</b>
        <i>119</i>&nbsp; }
        <i>120</i>&nbsp;
        <i>121</i>&nbsp; /**
        <i>122</i>&nbsp; * Adds points to the score of this player.
        <i>123</i>&nbsp; *
        <i>124</i>&nbsp; * @param points
        <i>125</i>&nbsp; * The amount of points to add to the points this player already
        <i>126</i>&nbsp; * has.
        <i>127</i>&nbsp; */
        <i>128</i>&nbsp; public void addPoints(int points) {
        <b class="nc"><i>129</i>&nbsp; score += points;</b>
        <i>130</i>&nbsp; }
        <i>131</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
